import { menuDataType } from '@/redux/interface/index'
import {produce} from "immer";
import * as types from '@/redux/constant'

const initState:menuDataType ={
   currentRouteKey:'',
   crumbList:[],
   collapse:false,
   allRouter:[],
}
const menuData = (preState: menuDataType = initState, action: any) => produce(preState,draftState=>{
   let {type,data} = action
   switch(type){
          case types.SET_CURRENT_OUTER_KEY:
             draftState.currentRouteKey = data
             break;

          case types.SET_CRUMB_LIST:
              draftState.crumbList = [...data]
              break;

          case types.SET_COLLAPSE:
              draftState.collapse = data
               break;

          case types.SET_ALL_ROUTER:
              draftState.allRouter = [...data]
              break;

          default:
              return draftState;
        }
})

export default menuData


